<template>
  <div class="page-warapper">
    <el-card>
      <el-tabs>
        <!-- 第一标签页 -->
        <el-tab-pane label="登录信息">
          <el-form>
            <el-form-item label="用户名" style="width:50%">
              <el-input v-model="formData.username" />
            </el-form-item>
            <el-form-item label="密码" style="width:50%">
              <el-input v-model="formData.password" />
            </el-form-item>
            <el-form-item>
              <el-button @click="submit">更新</el-button>
              <el-button @click="reset">重置</el-button>
            </el-form-item>
          </el-form>
        </el-tab-pane>
        <!-- 第二标签页 -->
        <el-tab-pane label="个人详情">
          <user-info />
        </el-tab-pane>
        <!-- 第三标签页 -->
        <el-tab-pane label="网页信息">
          <job-info />
        </el-tab-pane>
      </el-tabs>
    </el-card>
  </div>
</template>

<script>
import { getUserDetailById } from '@/api/user'
import { saveUserDetailById } from '@/api/employee.js'
import UserInfo from './components/user-info.vue'
import JobInfo from './components/job-info.vue'
export default {
  components: {
    UserInfo,
    JobInfo
  },
  data() {
    return {
      userID: this.$route.params.id,

      formData: {
        username: '',
        password: ''

      },
      data: {}
    }
  },
  async created() {
    this.data = await getUserDetailById(this.userID)
    this.formData.username = this.data.username
  },
  methods: {
    async submit() {
      this.data.usernmae = this.formData.username || this.data.usernmae
      this.data.password = this.formData.password || this.data.password
      //   console.log('更新的数据', this.data)

      await saveUserDetailById(this.data)
      this.$message.success('更改成功')
    },
    reset() {
      this.formData.username = this.data.usernmae
      this.formData.password = ''
    }
  }
}
</script>

<style>

</style>
